package cn.zsb.service;

import cn.zsb.dao.AdvtiseDao;
import cn.zsb.entity.Advtise;
import cn.zsb.entity.Page;
import org.apache.ibatis.session.SqlSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class AdvtiseService {

    public static final Logger Log = LoggerFactory.getLogger(AdvtiseService.class);
    @Autowired
    AdvtiseDao dao;

    public int add(Advtise adv) {
        return dao.add(adv);

    }

    public int update(Advtise adv) {

        return dao.update(adv);

    }

    public int del(long id) {

        return dao.del(id);

    }

    public Advtise get(long id) {

        return dao.get(id);

    }

    public List<Advtise> findAll() {

        List<Advtise> list = dao.findAll();
        return dao.findAll();

    }

    public Page<Advtise> page(String title, Date start, Date end, int pageNo, int pageSize) {

        List<Advtise> list = dao.search1(title, start, end, pageNo, pageSize);
        int total = dao.findTotal(title, start, end);
        return new Page<>(list, pageNo, total, pageSize);

    }

    public int findTotal(String title, Date start, Date end) {

        return dao.findTotal(title, start, end);

    }

    public int checkurl(String url, long id) {
        return dao.checkurl(url, id);
    }
}
